import pygame
import random
from pygame.locals import *
class BaseMan(object):
    def __init__(self,screen):
        self.screen = screen
        self.x = 20
        self.y = 630
        self.imageName = 'C:/Users/25238/Pictures/Saved Pictures/强哥缩小版.png'
        self.image = pygame.image.load(self.imageName)
        pass
    def display(self):
        self.screen.blit(self.image,(self.x,self.y))
        pass
    def moveup(self):
        if self.y > 30:
            self.y -= 50
    def movedown(self):
        if self.y < 600:
            self.y += 50
    def moveleft(self):
        if self.x > 0:
            self.x -= 50
            pass
    def moveright(self):
        if self.x <= 950:
            self.x += 50
            pass
        pass
class enemyMan(object):
    def __init__(self,screen):
        self.direction = 'up'
        self.screen = screen
        self.x = 950
        self.y = 640
        self.imageName = 'C:/Users/25238/Pictures/Saved Pictures/美女敌人.png'
        self.image = pygame.image.load(self.imageName)
        self.list = []
        pass
    def display(self):
        self.screen.blit(self.image,(self.x,self.y))
        list2 = []
        for item in self.list:
            pass
    def move(self):
        if self.direction == 'up':
            self.y -= 0.1
            pass
        elif self.direction == 'down':
            self.y += 0.1
        if self.y > 630 :
            self.direction = 'up'
            pass
        if self.y < 20 :
            self.direction = 'down'
            pass
        pass
    def shout(self):
        num = random.randint(1,1000)
        if num == 5 :
            newbullet = enemybullet(self.x,self.y,self.screen)
            self.list.append(newbullet)
            pass
        pass
class enemybullet(object):
    def __init__(self,x,y,screen):
        self.x = x
        self.y = y
        self.screen = screen
        self.imageName = 'C:/Users/25238/Pictures/Saved Pictures/飞吻.png'
        self.image = pygame.image.load(self.imageName)
        pass
    def display(self):
        self.screen.blit(self.image,(self.x,self.y))
        pass
    def judge(self):
        if self.x <= 0:
            return True
        else:
            return False
        pass
def main():
    screen = pygame.display.set_mode((1000,700),depth=32)
    background = pygame.image.load('C:/Users/25238/Pictures/Saved Pictures/malu.png')
    hero = BaseMan(screen)
    enemy = enemyMan(screen)
    while True:
        screen.blit(background,(0,0))
        hero.display()
        enemy.display()
        enemy.move()
        enemy.shout()
        pygame.display.update()
        eventlist = pygame.event.get()
        for event in eventlist:
            if event.type == QUIT:
                exit()
                pass
            elif event.type == KEYDOWN:
                if event.key == K_UP:
                    print('up')
                    hero.moveup()
                    pass
                if event.key == K_DOWN:
                    print('down')
                    hero.movedown()
                    pass
                if event.key == K_RIGHT:
                    print('right')
                    hero.moveright()
                    pass
                if event.key == K_LEFT:
                    print('left')
                    hero.moveleft()
                    pass
                pass
            pass
        pass
    pass
if __name__ =='__main__':
    main()